package movieGandalf.dataObjects;

import java.math.BigInteger;
import java.sql.Connection;
import java.util.List;

import movieGandalf.database.MovieTools;
import movieGandalf.logicGuiConnection.*;

public class ActorImp implements Actor{
	
	private BigInteger id;
	private String name;
	private String imdbName;
	private Gender gender;
	
	/*constructor*/
	
	public ActorImp(BigInteger id,String name, String imdbName, Gender gender){
		this.id = id;
		this.name = name;
		this.imdbName = imdbName;
		this.gender = gender;
	}
	
	/*getters*/
	
	public BigInteger getID(){
		return id;
	}
	
	public String getName(){
		return name;
	}
	
	public String getImdbName(){
		return imdbName;
	}
	
	public Gender getGender() {
		return this.gender;
	}
	
	public String getGenderString(){
		if (gender == null)
			return null;
		
		return gender.toString();
	}

	public boolean isMale() {
		return this.gender.equals(Gender.MALE);
	}

	public boolean isFemale() {
		return this.gender.equals(Gender.FEMALE);
	}
	
	public List<Role> getRoles() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return null;
		
		return MovieTools.getRoles(conn, this.getID());
	}
	
	/*setters*/
	
	public void setID(BigInteger id){
		this.id = id;
	}
	
	public void setName(String name){
		this.name = name;
	}

	public void setImdbName(String name){
		this.name = name;
	}

	public boolean update() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return false;
		
		return MovieTools.updateActor(conn, this);
	}
	
	public boolean delete() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return false;
		
		return MovieTools.deleteObject(conn,this);
	}
}
